﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;

namespace TeamDeploy.Tasks.Tests
{
    /// <summary>
    /// Summary description for InstallTests
    /// </summary>
    [TestClass]
    public class InstallTests
    {

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [TestMethod]
        public void InstallExecute()
        {

            Install task = new Install();

            task.BuildEngine = new MockBuild();
            task.MSIPathFilename = Path.Combine(@"C:\tfs\teamdeploy\InstallUninstalTests\Debug", "InstallUninstallTests.msi");
            task.RemoteExecutePathFilename = "c:\\pstools\\psexec2.exe";
            task.ExtraArgs = "SETUPENV=SystemTest";
            task.TargetMachine = Environment.MachineName;
            task.OverridePSExecArgs = "-i 0 -accepteula -u Administrator -p P@ssw0rd";
            Assert.IsTrue(task.Execute(), "Execute Failed");
            Assert.IsTrue(Utility.IsInstalled("InstallUninstallTests", Environment.MachineName), "Product did not install");


        }
    }
}
